﻿namespace WMS6.Web.Configuration
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class CCDiscrepanceRuleQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlCcAdjRuleID;
        protected DropDownList ddlDescr;
        protected DropDownList ddlIsActive;
        protected DropDownList ddlIsActiveOper;
        protected DropDownList ddlNegAdjExpiryDate;
        protected DropDownList ddlNegAdjLot;
        protected DropDownList ddlNegAdjProduceDate;
        protected DropDownList ddlNegAdjReceiptDate;
        protected DropDownList ddlPosAdjExpiryDate;
        protected DropDownList ddlPosAdjLot;
        protected DropDownList ddlPosAdjProduceDate;
        protected DropDownList ddlPosAdjReceiptDate;
        protected DropDownList ddlQtyGtrZero;
        protected DropDownList ddlQtyGtrZeroOpr;
        protected HtmlForm F2214;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlImage img2;
        protected HtmlImage img3;
        protected HtmlImage img4;
        protected HtmlImage img5;
        protected HtmlImage img6;
        protected HtmlImage img7;
        protected Label lblBu;
        protected Label lblCcAdjRuleID;
        protected Label lblDescr;
        protected Label lblIsActive;
        protected Label lblNegAdjExpiryDate;
        protected Label lblNegAdjLot;
        protected Label lblNegAdjProduceDate;
        protected Label lblNegAdjReceiptDate;
        protected Label lblPosAdjExpiryDate;
        protected Label lblPosAdjLot;
        protected Label lblPosAdjProduceDate;
        protected Label lblPosAdjReceiptDate;
        protected Label lblQtyGtrZero;
        protected HtmlLink mycss;
        protected ScriptManager ScriptManager1;
        protected TextBox txtCcAdjRuleID;
        protected TextBox txtDescr;
        protected TextBox txtNegAdjExpiryDate;
        protected TextBox txtNegAdjExpiryDate2;
        protected TextBox txtNegAdjLot;
        protected TextBox txtNegAdjProduceDate;
        protected TextBox txtNegAdjProduceDate2;
        protected TextBox txtNegAdjReceiptDate;
        protected TextBox txtNegAdjReceiptDate2;
        protected TextBox txtPosAdjExpiryDate;
        protected TextBox txtPosAdjExpiryDate2;
        protected TextBox txtPosAdjLot;
        protected TextBox txtPosAdjProduceDate;
        protected TextBox txtPosAdjProduceDate2;
        protected TextBox txtPosAdjReceiptDate;
        protected TextBox txtPosAdjReceiptDate2;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("CCDiscrepanceRuleList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("CCDiscrepanceRuleList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void InitDropDownLists()
        {
            base.InitQueryDDL(this.ddlCcAdjRuleID, 0);
            base.InitQueryDDL(this.ddlDescr, 0);
            base.InitQueryDDL(this.ddlPosAdjLot, 0);
            base.InitQueryDDL(this.ddlPosAdjProduceDate, 1);
            base.InitQueryDDL(this.ddlPosAdjExpiryDate, 1);
            base.InitQueryDDL(this.ddlPosAdjReceiptDate, 1);
            base.InitQueryDDL(this.ddlNegAdjLot, 0);
            base.InitQueryDDL(this.ddlNegAdjProduceDate, 1);
            base.InitQueryDDL(this.ddlNegAdjExpiryDate, 1);
            base.InitQueryDDL(this.ddlNegAdjReceiptDate, 1);
            base.InitQueryDDL(this.ddlIsActiveOper, 0);
            base.InitQueryDDL(this.ddlQtyGtrZeroOpr, 0);
            base.InitIsActiveDDL(this.ddlIsActive, 0);
            base.InitIsActiveDDL(this.ddlQtyGtrZero, 0);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnNew.Visible = false;
                this.btnExport.Visible = false;
                this.ddlIsActive.SelectedValue = "Y";
                this.ddlIsActive.Enabled = false;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.InitDropDownLists();
                this.LoadData();
            }
        }

        public string CcAdjRuleID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCcAdjRuleID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCcAdjRuleID.Text.Trim(), this.ddlCcAdjRuleID.SelectedValue);
                }
                return "";
            }
        }

        public string Descr
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDescr.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDescr.Text.Trim(), this.ddlDescr.SelectedValue);
                }
                return "";
            }
        }

        public string IsActive
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsActive.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsActive.SelectedValue, this.ddlIsActiveOper.SelectedValue);
                }
                return "";
            }
        }

        public string NegAdjExpiryDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtNegAdjExpiryDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtNegAdjExpiryDate.Text.Trim(), this.ddlNegAdjExpiryDate.SelectedValue, this.txtNegAdjExpiryDate2.Text.Trim(), "NegAdjExpiryDate");
                }
                return "";
            }
        }

        public string NegAdjLot
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtNegAdjLot.Text.Trim()))
                {
                    return base.GetParamsString(this.txtNegAdjLot.Text.Trim(), this.ddlNegAdjLot.SelectedValue);
                }
                return "";
            }
        }

        public string NegAdjProduceDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtNegAdjProduceDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtNegAdjProduceDate.Text.Trim(), this.ddlNegAdjProduceDate.SelectedValue, this.txtNegAdjProduceDate2.Text.Trim(), "NegAdjProduceDate");
                }
                return "";
            }
        }

        public string NegAdjReceiptDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtNegAdjReceiptDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtNegAdjReceiptDate.Text.Trim(), this.ddlNegAdjReceiptDate.SelectedValue, this.txtNegAdjReceiptDate2.Text.Trim(), "NegAdjReceiptDate");
                }
                return "";
            }
        }

        public string PosAdjExpiryDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtPosAdjExpiryDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtPosAdjExpiryDate.Text.Trim(), this.ddlPosAdjExpiryDate.SelectedValue, this.txtPosAdjExpiryDate2.Text.Trim(), "PosAdjExpiryDate");
                }
                return "";
            }
        }

        public string PosAdjLot
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtPosAdjLot.Text.Trim()))
                {
                    return base.GetParamsString(this.txtPosAdjLot.Text.Trim(), this.ddlPosAdjLot.SelectedValue);
                }
                return "";
            }
        }

        public string PosAdjProduceDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtPosAdjProduceDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtPosAdjProduceDate.Text.Trim(), this.ddlPosAdjProduceDate.SelectedValue, this.txtPosAdjProduceDate2.Text.Trim(), "PosAdjProduceDate");
                }
                return "";
            }
        }

        public string PosAdjReceiptDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtPosAdjReceiptDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtPosAdjReceiptDate.Text.Trim(), this.ddlPosAdjReceiptDate.SelectedValue, this.txtPosAdjReceiptDate2.Text.Trim(), "PosAdjReceiptDate");
                }
                return "";
            }
        }

        public string QtyGtrZero
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlQtyGtrZero.SelectedValue))
                {
                    return base.GetParamsString(this.ddlQtyGtrZero.SelectedValue, this.ddlPosAdjReceiptDate.SelectedValue);
                }
                return "";
            }
        }
    }
}

